import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './vuex/index'
import axios from 'axios'
/* @desc:httpInterceptor */
import {
  request,
  response
} from './service/httpInterceptor'
axios.interceptors.request.use(request)
axios.interceptors.response.use(response);

/*ElementUI*/
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
// 引入echarts
import echarts from 'echarts'
Vue.prototype.$echarts = echarts

/* base style */
import '../public/lib/css/base.scss'

/*filter*/
import filter from './plugin/filter'
Vue.use(filter)

/*method*/
import pluginMethod from './plugin/method'
Vue.use(pluginMethod)


/*component*/
import component from './plugin/component'
Vue.use(component)

import VueQuillEditor from 'vue-quill-editor'
// require styles 引入样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)

//测试写死的session
// sessionStorage.setItem("h_token",'ZHdI2BOF88gQLtVi') 

router.beforeEach(function (to, from, next) {
  if (to.meta && to.meta.title) {
    document.title = to.meta.title;
  }
  if (to.name != 'Login') {
    if (sessionStorage.getItem('h_token')) {
      next();
    } else {
      next({
        path: '/Login'
      });
    } 
  } else {
    next();
  }
});
Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')